package com.wz.project.num.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.wz.framework.aspectj.lang.annotation.Log;
import com.wz.framework.aspectj.lang.enums.BusinessType;
import com.wz.project.num.domain.BasRoadwayNum;
import com.wz.project.num.service.IBasRoadwayNumService;
import com.wz.framework.web.controller.BaseController;
import com.wz.framework.web.domain.AjaxResult;
import com.wz.common.utils.poi.ExcelUtil;
import com.wz.framework.web.page.TableDataInfo;

/**
 * 1Controller
 * 
 * @author wz
 * @date 2024-01-07
 */
@Controller
@RequestMapping("/num/num")
@EnableScheduling
public class BasRoadwayNumController extends BaseController
{
    private String prefix = "num/num";

    @Autowired
    private IBasRoadwayNumService basRoadwayNumService;

//    @RequiresPermissions("num:num:view")
    @GetMapping()
    public String num()
    {
        return prefix + "/num";
    }

    @Scheduled(cron = "0 0 12 * * ?")
    public void AutoCall() {
        BasRoadwayNum basRoadwayNum = new BasRoadwayNum();
        int i = basRoadwayNumService.updateBasRoadwayNum(basRoadwayNum);
    }

    /**
     * 查询1列表
     */
//    @RequiresPermissions("num:num:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(BasRoadwayNum basRoadwayNum)
    {
        startPage();
        List<BasRoadwayNum> list = basRoadwayNumService.selectBasRoadwayNumList(basRoadwayNum);
        return getDataTable(list);
    }

    /**
     * 导出1列表
     */
//    @RequiresPermissions("num:num:export")
    @Log(title = "1", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(BasRoadwayNum basRoadwayNum)
    {
        List<BasRoadwayNum> list = basRoadwayNumService.selectBasRoadwayNumList(basRoadwayNum);
        ExcelUtil<BasRoadwayNum> util = new ExcelUtil<BasRoadwayNum>(BasRoadwayNum.class);
        return util.exportExcel(list, "num");
    }

    /**
     * 新增1
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存1
     */
    @RequiresPermissions("num:num:add")
    @Log(title = "1", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(BasRoadwayNum basRoadwayNum)
    {
        return toAjax(basRoadwayNumService.insertBasRoadwayNum(basRoadwayNum));
    }

    /**
     * 修改1
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        BasRoadwayNum basRoadwayNum = basRoadwayNumService.selectBasRoadwayNumById(id);
        mmap.put("basRoadwayNum", basRoadwayNum);
        return prefix + "/edit";
    }

    /**
     * 修改保存1
     */
    @RequiresPermissions("num:num:edit")
    @Log(title = "1", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(BasRoadwayNum basRoadwayNum)
    {
        return toAjax(basRoadwayNumService.updateBasRoadwayNum(basRoadwayNum));
    }

    /**
     * 删除1
     */
    @RequiresPermissions("num:num:remove")
    @Log(title = "1", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(basRoadwayNumService.deleteBasRoadwayNumByIds(ids));
    }

}

